package com.jhy.new2025.doubelpointer;

/**
 * 输入：s = ["h","e","l","l","o"]
 * 输出：["o","l","l","e","h"]
 */
public class ReverseString {
    /**
     * 输入和输出
     *
     * @param s
     */
    public static void reverseString(char[] s) {
        int length = s.length;
        for (int i = 0; i < s.length / 2; i++, length--) {
            char temp = s[i];
            s[i] = s[length - 1];
            s[length - 1] = temp;
        }
    }

    public static void main(String[] args) {
        char[] s = new char[]{'h', 'e', 'l', 'l', 'o'};
        reverseString(s);
        System.out.println("----");
    }
}
